package com.mzj.saas.jobs.lock.repository;

import com.mzj.saas.jobs.lock.entity.LockHouseSetting;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

public interface LockHouseSettingRepository extends PagingAndSortingRepository<LockHouseSetting, Long>, JpaSpecificationExecutor<LockHouseSetting> {
    LockHouseSetting findByLockId(Long lockId);

    @Query(value = "UPDATE saas_lock_house_setting SET pwd_status=?1, pwd_index_num=?2 WHERE lock_id = (SELECT id FROM saas_smart_lock WHERE sn = ?3)", nativeQuery = true)
    void updatePwdStatus(Integer status, Integer pwdIndexNum, String sn);
}
